import VueRouter from "vue-router";
import GameStore from '@/pages/GameStore'
import AloneGameCategoryData from '@/pages/AloneGameCategoryData'
import SearchGames from '@/pages/SearchGames'
import LoginPage from '@/pages/LoginPage'
import PersonalCenter from '@/pages/PersonalCenter'
import OrderShow from '@/pages/OrderShow'
const router=new VueRouter({
    routes:[
        {
            name:'gameStore',
            path:'/gameStore',
            alias:'/',
            component:GameStore,
            meta:{universal:true},
        },
        {
            name:'aloneGameCategoryData',
            path:'/aloneGameCategoryData/:allGames/:allGameSpecification/:gameCategory/:others/:gameSize',
            component:AloneGameCategoryData,
            meta:{universal:true},
        },
        {
            name:'searchGames',
            path:'/searchGames/:searchGames/:allGameSpecification/:searchGameCategory/:others',
            component:SearchGames,
            meta:{universal:true},
        },
        {
            name:'loginPage',
            path:'/loginPage',
            component:LoginPage,
            meta:{universal:true},//未登录也可以浏览商城查询商品查看更多
        },
        {
            name:'personalCenter',
            path:'/personalCenter',
            component:PersonalCenter,
        },
        {
            name:'orderShow',
            path:'/orderShow/:page/:pageSize',
            props($route){
                return{
                    page:$route.params.page,
                    pageSize:$route.params.pageSize
                }
            },
            component:OrderShow,
        }
    ]
})
router.beforeEach((to,from,next)=>{
    if(to.meta.universal===true||localStorage.getItem("clientele")!==null){
        next();
    }
})
export default router;